﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace COFE.Core.Tasks
{
    public static class COFETaskShared
    {
        public static TaskProgressDispatcher TaskProgressDispatcher = new TaskProgressDispatcher();


        #region Data

        [ThreadStatic]
        private static ICOFEActionQueue _currentTask;

        //[ThreadStatic]
        //public static ICOFEChildTask _currentChildTask;

        [ThreadStatic]
        public static CancellationToken _cancellationToken;

        #endregion


        /// <summary>
        /// Return the current running task.
        /// </summary>     
        public static ICOFEActionQueue CurrentTask { get { return _currentTask; } internal set { _currentTask = value; } }

        ///// <summary>
        ///// Return the current running child task.
        ///// </summary>      
        //public static ICOFEChildTask CurrentChildTask { get { return _currentChildTask; } internal set { _currentChildTask = value; } }

        /// <summary>
        /// CancellationToken, set when Task is running (IEntryTaskExtensions)
        /// </summary>
        public static CancellationToken CancellationToken { get { return _cancellationToken; } internal set { _cancellationToken = value; } }
    }
}
